﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NhJump.Persistence.Context.ThreadLocalBinding
{
    public class ThreadLocalPersistenceBinder : IUnitOfWorkBinder
    {
        [ThreadStatic] 
        static UnitOfWork _threadUnitOfWork = null;

        public UnitOfWork GetCurrent()
        {
            return _threadUnitOfWork;    
        }

        public void Bind(UnitOfWork unitOfWork)
        {
            _threadUnitOfWork = unitOfWork;
        }

        public void UnBind()
        {
            _threadUnitOfWork = null;
        }
    }
}
